package what.basic.collection;

import java.util.Comparator;

public class student implements Comparable {
private int sid;
private String firstname;
private String lastname;
public student (int id,String fname,String lname){
	sid=id;
	firstname=fname;
	lastname=lname;
}
public int getstudentid(){
	return sid;
}
public String getfirstname(){
	return firstname;
}
public String getlastname(){
	return lastname;
}
public String getfullname(){
	return getfirstname()+""+getlastname();
}
public int hashCode(){
	return sid;
}
public boolean equals(Object o){
	boolean isequal=false;
	if((o!=null)&&(o instanceof student)){
		student target=(student)o;
		isequal=(target.getstudentid()==this.getstudentid());
	}
	return isequal;
}
public int compareTo(Object o) {
	assert((o instanceof student)&& (o!=null));
	student s=(student)o;
	int re=lastname.compareTo(s.getlastname());
	if(re==0)
		re=firstname.compareTo(s.getfirstname());
	return re;
}
}
class studentcomparator implements Comparator<student>{

	public int compare(student o1, student o2) {
		int re=o1.getstudentid()-o2.getstudentid();
		return re;
	}
	
}